{include file="public/header"/}
<script src="{__PUBLIC_PATH}/common/js/jquery.js?v={$version}"></script>
<script src="{__PUBLIC_PATH}/admin/pcf/pcfcms.js?v={$version}"></script>
<link rel="stylesheet" href="{__PUBLIC_PATH}/admin/pcf/pcfbase.css?v={$version}"/>
</head>
<body>
<div class="layui-form">
<div class="layui-fluid" style="padding-bottom:83px;border:0;">
<div class="layui-col-sm12">
<div class="layui-card pcf10">
    <div class="layui-card-body">
        <div class="layui-form-item">
            <label class="layui-form-label">角色名</label>
            <div class="layui-input-inline">
                <input name="name" placeholder="请输入角色名" class="layui-input" lay-verType="tips" lay-verify="required" required/>
            </div>
            <div class="layui-form-mid layui-word-aux">
                请填写管理员的账号，建议使用<span class="layui-bg-red">中文汉字或英文单词</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">在线升级</label>
            <div class="layui-input-block">
              <input type="checkbox" name="online_update" title="允许操作">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文档权限</label>
            <div class="layui-input-block">
              <input type="checkbox" name="only_oneself" title="只看自己发布的文档">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注:</label>
            <div class="layui-input-block">
                <textarea name="remark" placeholder="请输入备注" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
                <input type="radio" name="status" value="1" title="启用" checked>
                <input type="radio" name="status" value="0" title="禁用">
            </div>
        </div>
        {volist name="authmenu" id="vo"}
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header layui-bg-cyan">{$vo.name}</div>
                    {if($vo.child)}
                    <div class="layui-card-body">
                        <div class="layui-col-md12">
                            {volist name="$vo.child" id="v1"}
                            {if($v1.child)}
                            <div class="layui-card" id="mlist_{$v1.id}" style="border:1px solid #2f4055;margin-bottom:10px;">
                                <div class="layui-card-header">{$v1.name}
                                    <div class="layui-btn-group fr">
                                        <input type="button" class="layui-btn layui-btn-primary layui-btn-sm" value="全选" onclick="$.input.checkbox_all('mlist_{$v1.id}')" />
                                        <input type="button" class="layui-btn layui-btn-primary layui-btn-sm" value="全不选" onclick="$.input.checkbox_none('mlist_{$v1.id}')" />
                                        <input type="button" class="layui-btn layui-btn-primary layui-btn-sm" value="反选" onclick="$.input.checkbox_anti('mlist_{$v1.id}')" />
                                    </div>
                                </div>
                                <div class="layui-card-body">
                                    {volist name="$v1.child" id="v2"}
                                    <div class="layui-form-item" id="mlist_{$v2.id}">
                                        <label class="layui-form-label">{$v2.name}</label>
                                        <div class="layui-input-inline" style="width: auto">
                                            <div class="layui-btn-group">
                                                <input type="button" class="layui-btn layui-btn-primary layui-btn-sm" value="全选" onclick="$.input.checkbox_all('mlist_{$v2.id}')" />
                                                <input type="button" class="layui-btn layui-btn-primary layui-btn-sm" value="全不" onclick="$.input.checkbox_none('mlist_{$v2.id}')" />
                                                <input type="button" class="layui-btn layui-btn-primary layui-btn-sm" value="反选" onclick="$.input.checkbox_anti('mlist_{$v2.id}')" />
                                            </div>
                                            {if($v2.child)}
                                            {volist name="$v2.child" id="v3"}
                                                {if ($admin_popedom == -1)}
                                                    <input type="checkbox" name="popedom[]" value="{$v3.id}" title="{$v3.name}">
                                                {else/}
                                                    {if (!empty($admin_popedom) && in_array($v3.id, $admin_popedom))}
                                                    <input type="checkbox" name="popedom[]" value="{$v3.id}" title="{$v3.name}">
                                                    {/if}
                                                {/if}
                                            {/volist}
                                            {/if}
                                        </div>
                                    </div>
                                    {/volist}
                                </div>
                            </div>
                            {/if}
                            {/volist}
                        </div>
                    </div>
                    {/if}
                  <div style="clear:both;"></div>
                </div>
            </div>
        {/volist}
        <div style="clear:both;"></div>
    </div>
    <div class="submit-info text-center">
        <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
    </div>
</div>
</div>
<div class="pcfclear"></div>
</div>
</div>
{include file="public/footer"/}
<script>
    layui.use('form', function(){
        var $ = layui.$,
            layer = layui.layer,
            form = layui.form;
            //监听提交
            form.on('submit(formSubmit)', function(data){
                layer.load(2);
                $.ajax({
                    type : 'post',
                    url : "{:url('/system.authrole/add')}",
                    data : data.field,
                    dataType : 'json',
                    success : function(res){
                        layer.closeAll('loading');
                        if(0 === res.code){
                            layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                                parent.window.location.href = res.url;
                            });
                        }else{
                            layer.msg(res.msg, {icon: 2, time: 1000});
                        }
                    },
                    error: function(e){
                        layer.closeAll('loading');
                        layer.msg("未知错误，操作中断！", {icon: 2, time: 1000});
                    }
                });
                return false;
            });
    });
</script>
</body>
</html>